from flask import Blueprint, render_template, jsonify

from config.json_response import JsonResponse

# 类似RestController("/test")
test_bp = Blueprint('test', __name__, url_prefix='/test')


# 类似RequestMapping("/hi")
@test_bp.route("/hi", methods=["POST", "GET"])
def hi():
    return "小明,你好"


@test_bp.route('/hello')
def hello_world():  # put application's code here
    return jsonify({"code": 0, "data": "Hello World 2024", "msg": "查询成功"})


@test_bp.route('/json')
def hello_world_two():  # put application's code here
    return JsonResponse.success(data="Hello World 2024", code=200, msg="success").to_json()


name = '小明'
year = '2024'


@test_bp.route('/index')
def happy_new_year():
    return render_template('test/index.html', name=name, year=year)

